import request from '@/utils/request'

const filePath = {
	getCaptcha: '/captcha',
	upload: '/file/upload'
}

/**
 * 获取图形验证码 
 **/
export function getCaptcha(){
	return request({
		url: filePath.getCaptcha,
		method: 'get',
		responseType: 'arraybuffer'
	})
}

/**
 * 上传文件 
 **/
export function upload(data){
	const formData = new FormData()
	Object.keys(data).forEach((key) => {
		formData.append(key,data[key])
	})
	return request({
		url: filePath.upload,
		method: 'post',
		headers: {
			"Content-type": "multipart/form-data"
		},
		data: formData
	})
}

